describe("InputUtil", function() {
    describe("nextValidState", function() {
        var input = new DecimalInput(',');

        it("should accept valid numbers", function() {
            expect(input.nextValidState('')).toEqual('');
            expect(input.nextValidState('1')).toEqual('1');
            expect(input.nextValidState('1,')).toEqual('1,');
            expect(input.nextValidState('1,3')).toEqual('1,3');
        });

        it("should refuse invalid chars", function() {
            expect(input.nextValidState('a')).toEqual('');
            expect(input.nextValidState('1.')).toEqual('1');
            expect(input.nextValidState('1$')).toEqual('1');
            expect(input.nextValidState('1,;')).toEqual('1,');
            expect(input.nextValidState('1,3,')).toEqual('1,3');
        });

        it("should refuse decimal digits beyond the maximum", function() {
            var inputMaxDecPlaces = new DecimalInput(',', 2);
            expect(inputMaxDecPlaces.nextValidState('a')).toEqual('');
            expect(inputMaxDecPlaces.nextValidState('1.')).toEqual('1');
            expect(inputMaxDecPlaces.nextValidState('1$')).toEqual('1');
            expect(inputMaxDecPlaces.nextValidState('1,;')).toEqual('1,');
            expect(inputMaxDecPlaces.nextValidState('1,3,')).toEqual('1,3');
            expect(inputMaxDecPlaces.nextValidState('1,34')).toEqual('1,34');
            expect(inputMaxDecPlaces.nextValidState('1,345')).toEqual('1,34');
        });
    });
});
